package smile.webservicemain.dao;

import java.util.List;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import smile.entity.PostPart;
import smile.entity.User;
@IocBean
public class UserDao {

	@Inject
	private  Dao dao;
	private  User user;
	
	public  int insertUserDao(){
		 dao.insert(user);
		 return 1;
	}
	public  int deleteUserDao(){
		 dao.delete(user);
		 return 1;
	}
	public  int updateUserDao(){
		 dao.update(user);
		 return 1;
	}
	public  int selectUserDao(){
		int count =  dao.count(User.class);
		 return count;
	}
	public User login(String username, String password){
		User user = dao.fetch(User.class,Cnd.where("name","=",username).and("password","=",password));
		return user;
	}
	public List<PostPart> postList(String name){
		List<PostPart> postList = dao.query(PostPart.class, Cnd.where("create_user","=",name));
		return postList;
	}
}
